import bus from '@/bus'
import { renderButton, formatDate } from '@/util'
function getCurrentMonthFirst(){
  var date = new Date()
  date.setDate(1)
  var month = parseInt(date.getMonth() + 1)
  var day = date.getDate()
  if (month < 10) {
    month = '0' + month
  }
  if (day < 10) {
    day = '0' + day
  }
  return date.getFullYear() + '-' + month + '-' + day
}
let data = {
  status: 'pass',
  totalItem: 1,
  pageSize: window.$pageSize,
  currentPage: 1,
  form: {
    goldRecordTypeEnum: null,
    barCode: null,
    storeName: null,
    storeLinkName: null,
    storePhone: null,
    storeLinkName: null,
    orderSn: null,
    date: [getCurrentMonthFirst(), formatDate(new Date())]
  },
  options: {
    type: [{
      value: 'ORDER_PAYMENT',
      label: '抢购订单'
    }, {
      value: 'STOCK_IN',
      label: '扫码入库'
    }, {
      value: 'TASK_COMPLETE',
      label: '任务完成'
    }, {
      value: 'LOTTERY',
      label: '抽奖'
    }, {
      value: 'ORDER_CANCEL',
      label: '订单取消'
    }, {
      value: 'STOCK_OUT',
      label: '扫码退货'
    }, {
      value: 'STOCK_IN_DISTRIBUTOR',
      label: '扫码入库经销商'
    }, {
      value: 'STOCK_OUT_DISTRIBUTOR',
      label: '扫码退货经销商'
    }, {
      value: 'INVALID_COUPON',
      label: '优惠券失效'
    }, {
      value: 'INVALID_COUPON_DISTRIBUTOR',
      label: '优惠券经销商送的失效'
    }]
  },
  columns: [{
    title: '时间',
    key: 'recordDate',
    align: 'left',
    minWidth: 180,
  }, {
    title: '明细类型',
    key: 'goldRecordTypeEnum',
    align: 'left',
    minWidth: 150,
		render: (h, params) => {
      let text
      switch (params.row.goldRecordTypeEnum) {
        case 'ORDER_PAYMENT':
          text = '抢购订单'
          break
        case 'STOCK_IN':
          text = '扫码入库'
          break
        case 'TASK_COMPLETE':
          text = '任务完成'
          break
        case 'LOTTERY':
          text = '抽奖'
          break
        case 'ORDER_CANCEL':
          text = '订单取消'
          break
        case 'STOCK_OUT':
          text = '扫码退货'
          break
        case 'STOCK_IN_DISTRIBUTOR':
          text = '扫码入库经销商'
          break
        case 'STOCK_OUT_DISTRIBUTOR':
          text = '扫码退货经销商'
          break
        case 'INVALID_COUPON':
          text = '优惠券失效'
          break
        case 'INVALID_COUPON_DISTRIBUTOR':
          text = '优惠券经销商送的失效'
          break
        case 'STOCK_IN_ID':
          text = '扫码入库'
          break
        default:
          break
      }
			return h('div', text)
		}
  }, {
    title: '门店名称',
    key: 'storeName',
    minWidth: 180,
    align: 'left'
  }, {
    title: '联系人',
    key: 'storeLinkName',
    minWidth: 150,
    align: 'left'
  }, {
    title: '联系手机',
    key: 'storePhone',
    minWidth: 150,
    align: 'left'
  }, {
    title: '云豆变更',
    key: 'goldNum',
    minWidth: 120,
    align: 'right'
  }, {
    title: '科室',
    key: 'department',
    minWidth: 120,
    align: 'left'
  }, {
    title: '地区',
    key: 'region',
    minWidth: 150,
    align: 'left'
  }, {
    title: '经销商',
    key: 'distributor',
    minWidth: 200,
    align: 'left'
  }, {
    title: '操作',
    align: 'left',
    minWidth: 220,
    fixed: 'right',
    render: (h, params) => {
      let numDis = params.row.goldRecordTypeEnum !== 'ORDER_PAYMENT' && params.row.goldRecordTypeEnum !== 'ORDER_CANCEL'
      let codeDis = params.row.goldRecordTypeEnum !== 'STOCK_IN' && params.row.goldRecordTypeEnum !== 'STOCK_OUT' && params.row.goldRecordTypeEnum !== 'STOCK_IN_DISTRIBUTOR' && params.row.goldRecordTypeEnum !== 'STOCK_OUT_DISTRIBUTOR' && params.row.goldRecordTypeEnum !== 'STOCK_IN_ID'
      let taskDis = params.row.goldRecordTypeEnum !== 'TASK_COMPLETE'
      let numBtn = renderButton(h, { text: '单号', type: 'primary', disabled: numDis }, ()=>{ bus.$emit('onNum', { item: params.row })})
      let codeBtn = renderButton(h, { text: '条码', type: 'primary', disabled: codeDis }, ()=>{ bus.$emit('onNum', { item: params.row })})
      let taskBtn = renderButton(h, { text: '任务月份', type: 'primary', disabled: taskDis }, ()=>{ bus.$emit('onNum', { item: params.row })})
      return h('div', [numBtn, codeBtn, taskBtn])
    }
  }],
  data: []
}
export default data